package com.qfedu.edu.vipservice.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.edu.exception.BusinessException;
import com.qfedu.edu.po.Vip;
import com.qfedu.edu.result.ResponseCode;
import com.qfedu.edu.vipservice.mapper.VipMapper;
import com.qfedu.edu.vipservice.service.VipService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaobobo
 * @since 2024-11-05
 */
@Service
public class VipServiceImpl extends ServiceImpl<VipMapper, Vip> implements VipService {

    @Autowired
    private VipMapper vipMapper;

    @Override
    public Vip listUserByUsername(String username) {
        if(StringUtils.isEmpty(username)){
           throw new BusinessException(ResponseCode.PARAM_EXCEPTION);
        }
        QueryWrapper<Vip> vipQueryWrapper = new QueryWrapper<>();
        vipQueryWrapper.eq("name",username);
        Vip vip = vipMapper.selectOne(vipQueryWrapper);
        return vip;
    }
}
